package com.wxp.demo03.text;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.wxp.demo03.R;

/**
 * 1.3设置文本的颜色
 */
public class TextColorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.setTitle("1.3设置文本的颜色");
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_text_color);
        //设置文本颜色
        TextView textView1= findViewById(R.id.textView1);
        //红色
        textView1.setTextColor(Color.RED);
        TextView textView2= findViewById(R.id.textView2);
        //绿色
        textView2.setTextColor(Color.GREEN);
        TextView textView3= findViewById(R.id.textView3);
        //蓝色
        textView3.setTextColor(Color.BLUE);
        //自定义RGB颜色, 0x开头
        TextView textView4= findViewById(R.id.textView4);
        //FF04C6F6：青色
        textView4.setTextColor(0xFF04C6F6);

        //设置背景颜色
        TextView textView6= findViewById(R.id.textView6);
        textView6.setBackgroundResource(R.color.F65702);


        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.text_color), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
}